qui(
    function (require, exports, module) {
        Broadcast.Dao = $.extend({}, EpgWeb.Dao, {
            channelId: 0,
            programId: 0,
            cfgName: {
                platSettings: "platSettings",
                PlayPlatform: "PlayPlatform",
                entityName: "entityName",
                broadcastControl: "broadcastControl",
                reservation: "reservation",
                saveData: "saveData",
                getChannel: "getChannel",
                platforms: "platforms",
                programbroadcastControl: "programbroadcastControl"
            },
            //==============================================/
            createEntity: function () {
                var self = this;
                return {
                    id: self.channelId,
                    checkBossType: -1,
                    checkPublishType: -1,
                    checkCopyRightType: -1,
                    regionLimitArr: [],
                    onlineLimitArr: []
                }
            },
            createControlData: function () {
                var entity = {};
                entity.platform = 0;
                entity.availableStatus = false;
                entity.liveDelayTime = 0;
                entity.blacklist = "";
                entity.rejectSearch = false;
                entity.regionRejectSearch = false
                return entity;
            },
            copyControlData: function (oldData) {
                var self = this;
                var entity = self.createControlData();
                entity.platform = oldData.platform;
                entity.availableStatus = oldData.availableStatus;
                entity.liveDelayTime = oldData.liveDelayTime;
                entity.blacklist = oldData.blacklist;
                entity.rejectSearch = oldData.rejectSearch;
                entity.regionRejectSearch = oldData.regionRejectSearch;
                return entity;
            },
            //==============================================/
            getPlatSettings: function () {
                return this.getDataByName(this.cfgName.platSettings)
            },
            getPlatforms: function () {
                return this.getDataByName(this.cfgName.PlayPlatform)
            },
            getChannel: function () {
                return this.getDataByName(this.cfgName.getChannel).data
            },
            getBroadcastControls: function () {
                return this.getDataByName(this.cfgName.broadcastControl);
            },
            getProgramBroadcastControls: function () {
                return this.getDataByName(this.cfgName.programbroadcastControl);
            },
            //==============================================/
            savePlatSettings: function (data, callback) {
                var submitEntity = data;
                var options = {
                    url: EpgWeb.urlConfig.platSettingsSaveUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data, submitEntity);
                    },
                    error: function (data) {
                        callback.call(this, data, submitEntity);
                    }
                };
                Ancestor.Dao.ajax(options, '/channel/savePlatSettings');
            },

            saveData: function (copyToAll, data, callback) {
                var sendUrl = copyToAll ? EpgWeb.urlConfig.setBroadcastControlAllUrl : EpgWeb.urlConfig.setBroadcastControl;
                var options = {
                    url: sendUrl,
                    type: "post",
                    data: data,
                    dataType: "json",
                    success: function (data) {
                        callback(data);
                    },
                    error: function (data) {
                        callback(null);
                    }
                }
                Ancestor.Dao.ajax(options, sendUrl.replace("/api", ""));
            },
            saveEpisodeData: function (copyToAll, data, callback) {
                var sendUrl = EpgWeb.urlConfig.programBroadcastControlUrl;
                var options = {
                    url: sendUrl,
                    type: "post",
                    data: data,
                    dataType: "json",
                    success: function (data) {
                        callback(data);
                    },
                    error: function (data) {
                        callback(null);
                    }
                }
                Ancestor.Dao.ajax(options, sendUrl.replace("/api", ""));
            }
        })
    }
);